package com.zxp.springboot.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author shollin
 * @desc
 * @date 2021/7/20/020 6:58
 */
@Aspect
@Component
@Slf4j
public class CalcAop {

    @Pointcut("execution(public * com.zxp.springboot.service..CalServiceImpl.*(..) )")
    public void pointcut(){

    }

    @Before(value = "pointcut()")
    public void before(){
        log.info(" before ...");
    }

    @After(value = "pointcut()")
    public void after(){
        log.info(" After ...");
    }

    @Around(value = "pointcut()")
    public Object around(ProceedingJoinPoint pjp){

        log.info(" Around前 ...");
        Object result = null;
        try {
            result = pjp.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        log.info(" Around后 ...");
        return result;
    }
    @AfterReturning(value = "pointcut()")
    public void afterReturning(){
        log.info(" AfterReturning ...");
    }

    @AfterThrowing(value = "pointcut()")
    public void afterThrowing(){
        log.info(" AfterThrowing ...");
    }

}
